3 // Copyright (C) 2005 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32 // Permission to use, copy, modify, sell, and distribute this software
33 // is hereby granted without fee, provided that the above copyright
34 // notice appears in all copies, and that both that copyright notice and
35 // this permission notice appear in supporting documentation. None of
36 // the above authors, nor IBM Haifa Research Laboratories, make any
37 // representation about the suitability of this software for any
38 // purpose. It is provided "as is" without express or implied warranty.
41 * @file constructor_destructor_fn_imps.hpp
42 * Contains implementations of gp_ht_map_'s constructors, destructor,
43 * and related functions.
47 typename PB_ASSOC_CLASS_C_DEC::entry_allocator
48 PB_ASSOC_CLASS_C_DEC::s_entry_allocator;
53 PB_ASSOC_CLASS_C_DEC::
54 copy_from_range(It first_it, It last_it)
56 while (first_it != last_it)
57 insert(*(first_it++));
61 PB_ASSOC_CLASS_C_DEC::
62 PB_ASSOC_CLASS_NAME() :
63 my_ranged_probe_fn_base(Resize_Policy::get_init_size()),
64 m_a_entries(s_entry_allocator.allocate(
65 Resize_Policy::get_init_size())),
66 m_num_e(Resize_Policy::get_init_size()),
71 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
75 PB_ASSOC_CLASS_C_DEC::
76 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn) :
77 my_ranged_probe_fn_base(Resize_Policy::get_init_size(), r_hash_fn),
78 m_a_entries(s_entry_allocator.allocate(
79 Resize_Policy::get_init_size())),
80 m_num_e(Resize_Policy::get_init_size()),
85 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
89 PB_ASSOC_CLASS_C_DEC::
90 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
91 my_hash_eq_fn_base(r_eq_fn),
92 my_ranged_probe_fn_base(Resize_Policy::get_init_size(), r_hash_fn),
93 m_a_entries(s_entry_allocator.allocate(
94 Resize_Policy::get_init_size())),
95 m_num_e(Resize_Policy::get_init_size()),
100 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
104 PB_ASSOC_CLASS_C_DEC::
105 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn) :
106 my_hash_eq_fn_base(r_eq_fn),
107 my_ranged_probe_fn_base(Resize_Policy::get_init_size(),
108 r_hash_fn, r_comb_hash_fn),
109 m_a_entries(s_entry_allocator.allocate(
110 Resize_Policy::get_init_size())),
111 m_num_e(Resize_Policy::get_init_size()),
116 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
120 PB_ASSOC_CLASS_C_DEC::
121 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn) :
122 my_hash_eq_fn_base(r_eq_fn),
123 my_ranged_probe_fn_base(Resize_Policy::get_init_size(),
124 r_hash_fn, r_comb_hash_fn, r_probe_fn),
125 m_a_entries(s_entry_allocator.allocate(
126 Resize_Policy::get_init_size())),
127 m_num_e(Resize_Policy::get_init_size()),
132 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
136 PB_ASSOC_CLASS_C_DEC::
137 PB_ASSOC_CLASS_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn, const Comb_Probe_Fn& r_comb_hash_fn, const Probe_Fn& r_probe_fn, const Resize_Policy& r_resize_policy) :
138 my_hash_eq_fn_base(r_eq_fn),
139 my_resize_base(r_resize_policy),
140 my_ranged_probe_fn_base(Resize_Policy::get_init_size(),
141 r_hash_fn, r_comb_hash_fn, r_probe_fn),
142 m_a_entries(s_entry_allocator.allocate(
143 Resize_Policy::get_init_size())),
144 m_num_e(Resize_Policy::get_init_size()),
149 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_r_valid();)
153 PB_ASSOC_CLASS_C_DEC::
154 PB_ASSOC_CLASS_NAME(const PB_ASSOC_CLASS_C_DEC& r_other) :
155 my_hash_eq_fn_base(r_other),
156 my_resize_base(r_other),
157 my_ranged_probe_fn_base(r_other),
158 m_a_entries(s_entry_allocator.allocate(
160 m_num_e(r_other.m_num_e),
161 m_num_used_e(r_other.m_num_used_e)
167 for (size_type i = 0; i < m_num_e; ++i)
169 entry_pointer p_e =& r_other.m_a_entries[i];
170 if (p_e->m_stat == VALID_ENTRY_STATUS)
171 constructor_insert_new_imp((const_mapped_reference)p_e->m_value,
173 my_hash_traits_base::s_store_hash_indicator);
183 PB_ASSOC_DBG_ONLY(PB_ASSOC_CLASS_C_DEC::assert_valid();)
187 PB_ASSOC_CLASS_C_DEC::
188 ~PB_ASSOC_CLASS_NAME()
195 PB_ASSOC_CLASS_C_DEC::
196 swap(PB_ASSOC_CLASS_C_DEC& r_other)
198 PB_ASSOC_DBG_ONLY(assert_valid());
199 PB_ASSOC_DBG_ONLY(r_other.assert_valid());
201 std::swap(m_a_entries, r_other.m_a_entries);
203 std::swap(m_num_e, r_other.m_num_e);
205 std::swap(m_num_used_e, r_other.m_num_used_e);
207 my_ranged_probe_fn_base::swap(r_other);
209 my_hash_eq_fn_base::swap(r_other);
211 my_resize_base::swap(r_other);
213 PB_ASSOC_DBG_ONLY(my_cntnr_debug_base::swap(r_other));
215 PB_ASSOC_DBG_ONLY(assert_valid());
216 PB_ASSOC_DBG_ONLY(r_other.assert_valid());
221 PB_ASSOC_CLASS_C_DEC::
226 erase_all_valid_entries(m_a_entries, m_num_e);
228 s_entry_allocator.deallocate(m_a_entries, m_num_e);
233 PB_ASSOC_CLASS_C_DEC::
234 erase_all_valid_entries(entry_array a_entries_resized, size_type size)
236 for (size_type pos = 0; pos < size; ++pos)
238 entry_pointer p_e =& a_entries_resized[pos];
240 if (p_e->m_stat == VALID_ENTRY_STATUS)
241 p_e->m_value.~value_type();
247 PB_ASSOC_CLASS_C_DEC::
250 for (size_type i = 0; i < m_num_e; ++i)
251 m_a_entries[i].m_stat = (entry_status)EMPTY_ENTRY_STATUS;
254 #include <ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_store_hash_fn_imps.hpp>
255 #include <ext/pb_assoc/detail/gp_ht_map_/constructor_destructor_no_store_hash_fn_imps.hpp>